package com.webull.information.center.carwler.job;

import java.net.InetAddress;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.webull.information.center.carwler.common.model.CollectRecord;
import com.webull.information.center.carwler.dao.CollectRecordDao;
import com.webull.information.center.carwler.task.handler.StockReuteGuideHandler;
import com.webull.information.center.common.constants.Constants;

/**
 * 指数新闻
 * 
 * @author shimingjun
 * @date 2016年10月14日 下午3:08:37
 * @version 1.0
 * @since JDK 1.8
 */
@Component
public class News_ReutersGuideHomePage_Job implements SimpleJob {
	protected final Logger logger = LogManager.getLogger(getClass());
	private @Autowired CollectRecordDao collectRecordDao;
	private @Autowired StockReuteGuideHandler stockReuteGuideHandler;
	private final String collectJob = "news_ReutersGuideHomePage_Job";

	@Override
	public void execute(ShardingContext context) {
		logger.info("news_ReutersGuideHomePage_Job start");
		stockReuteGuideHandler.handlerByHomePage("zh", Constants.lang_zh_hant);
		stockReuteGuideHandler.handlerByHomePage("en", Constants.lang_en);
		stockReuteGuideHandler.handlerByHomePage("de", Constants.lang_de);
		stockReuteGuideHandler.handlerByHomePage("fr", Constants.lang_fr);
		Integer collId = collectRecordDao.add(backRecord());
		logger.info("news_ReutersGuideHomePage_Job end id:{}", collId);
	}


	private CollectRecord backRecord() {
		CollectRecord record = new CollectRecord();
		record.setCollectJob(collectJob);
		record.setExchangeCode("exchangeCode");
		record.setExchangeId(0);
		record.setRecordType(CollectRecord.RecordTypeConstants.NEWS);
		try {
			record.setCustomer(InetAddress.getLocalHost().getHostAddress());
		} catch (Exception e) {
		}
		return record;
	}

}
